package pri.zey.custom.tools.image;/**
 * Created by Administrator on 2016/3/16.
 */

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public abstract class RealizeAdapter<T> extends BaseAdapter {

    protected int layoutId;
    protected List<T> mDatas;
    protected Context mContext;

    public RealizeAdapter(List<T> mDatas, Context mContext, int layoutId) {
        this.mDatas = mDatas;
        this.mContext = mContext;
        this.layoutId = layoutId;
    }

    @Override
    public int getCount() {
        return mDatas == null ? 0 : mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = ViewHolder.get(position, convertView, parent, mContext, layoutId);
        setConvert(position, holder);
        return holder.getConvertView();
    }

    /**
     * 设置getView控件内容
     */
    public abstract void setConvert(int position, ViewHolder holder);
}
